//
//  LGCultureNameScrolViewController.m
//  ligenyun
//
//  Created by Mac on 2018/4/4.
//  Copyright © 2018年 stoneobs@icloud.com. All rights reserved.
//

#import "LGCultureNameScrolViewController.h"
#import "STRadioButton.h"
@interface LGCultureNameScrolViewController ()
@property(nonatomic, strong) UITextField                     *nameTextFiled;//名字
@property(nonatomic, strong) UITextField                     *textFiled;
@property(nonatomic, strong) STRadioButton                     *radioButton;
@property(nonatomic, strong) LGTypeChosedControl                     *dateControl;
@property(nonatomic, strong) LGTypeChosedControl                     *timeControl;
@end

@implementation LGCultureNameScrolViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"姓名测试打分";
    [self configSubView];
    // Do any additional setup after loading the view.
}
#pragma mark --subView
- (void)configSubView{
    __weak typeof(self) weakSelf =  self;
    UIImageView * bannerImageView = [[UIImageView alloc] initWithFrame:self.tableView.bounds];
    bannerImageView.image = [UIImage imageNamed:@"宗祠资料bg"];
    self.tableView.backgroundView = bannerImageView;
    UIView * header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, 300)];
    
    NSString * content = @"不怕生错命，就怕取错名。姓名之中有神机，非常运势免费算命网姓名测试打分根据八字五行生克，结合三才五格的吉凶生克和专业的姓名测试，为您的姓名测试打分。";
    STLabel * desLable = [[STLabel alloc] initWithFrame:CGRectMake(15, 20, UIScreenWidth - 15, 30)
                                                     text:content
                                                textColor:FirstTextColor
                                                     font:14
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentLeft];
    [NSString lableAutoAdjustheightWithLabel:desLable];
    [header addSubview:desLable];
    
    
    STLabel * indicatiorLable = [[STLabel alloc] initWithFrame:CGRectMake(15, desLable.bottom  +20, 200, 30)
                                                          text:@"您的姓氏:"
                                                     textColor:SecendTextColor
                                                          font:14
                                                   isSizetoFit:NO
                                                 textAlignment:NSTextAlignmentCenter];
    
    [NSString lableAutoAdjustWitdhWithLabel:indicatiorLable];
    [header addSubview:indicatiorLable];
    
    self.textFiled = [[UITextField alloc] initWithFrame:CGRectMake(indicatiorLable.right+ 20, 0, 140, 30)];
    self.textFiled.placeholder = @"请输入姓氏";
    [self.textFiled st_setBorderWith:1 borderColor:TM_lineColor cornerRadius:4];
    self.textFiled.centerY = indicatiorLable.centerY;
    self.textFiled.leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 15, 30)];
    self.textFiled.leftViewMode = UITextFieldViewModeAlways;
    [header addSubview:self.textFiled];
    
    
    STLabel * indicatiorNameLable = [[STLabel alloc] initWithFrame:CGRectMake(15, indicatiorLable.bottom  +20, 200, 30)
                                                          text:@"您的名字:"
                                                     textColor:SecendTextColor
                                                          font:14
                                                   isSizetoFit:NO
                                                 textAlignment:NSTextAlignmentCenter];
    
    [NSString lableAutoAdjustWitdhWithLabel:indicatiorNameLable];
    [header addSubview:indicatiorNameLable];
    
    self.nameTextFiled = [[UITextField alloc] initWithFrame:CGRectMake(indicatiorLable.right+ 20, 0, 140, 30)];
    self.nameTextFiled.placeholder = @"请输入姓氏";
    [self.nameTextFiled st_setBorderWith:1 borderColor:TM_lineColor cornerRadius:4];
    self.nameTextFiled.centerY = indicatiorNameLable.centerY;
    self.nameTextFiled.leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 15, 30)];
    self.nameTextFiled.leftViewMode = UITextFieldViewModeAlways;
    [header addSubview:self.nameTextFiled];
    
    
    STLabel * genderLable = [[STLabel alloc] initWithFrame:CGRectMake(15, indicatiorNameLable.bottom  +20, 200, 30)
                                                              text:@"性别:"
                                                         textColor:SecendTextColor
                                                              font:14
                                                       isSizetoFit:NO
                                                     textAlignment:NSTextAlignmentCenter];
    
    [NSString lableAutoAdjustWitdhWithLabel:genderLable];
    [header addSubview:genderLable];
    
    
    self.radioButton = [[STRadioButton alloc] initWithRadio:@[@"男",@"女"] andWithFrame:CGRectMake(genderLable.right, genderLable.top + 20, 200, 40)];
    self.radioButton.centerY = genderLable.centerY;
    self.radioButton.makenumOfarrayChecked = 0;
    [header addSubview:self.radioButton];
    
    
    STLabel * dateLable = [[STLabel alloc] initWithFrame:CGRectMake(15, genderLable.bottom  +20, 200, 30)
                                                      text:@"公历生日:"
                                                 textColor:SecendTextColor
                                                      font:14
                                               isSizetoFit:NO
                                             textAlignment:NSTextAlignmentCenter];
    
    [NSString lableAutoAdjustWitdhWithLabel:dateLable];
    [header addSubview:dateLable];
    
    
    self.dateControl = [[LGTypeChosedControl alloc] initWithFrame:CGRectMake(dateLable.right + 20, dateLable.top, 250, 30)
                                                                             title:[NSDate st_localCurrentDate].st_yyyyMMddByLineWithDate];
    [self.dateControl setClction:^(LGTypeChosedControl *control) {
        [weakSelf onSectedDateControl];
    }];
    [header addSubview:self.dateControl];
    
    
    self.timeControl = [[LGTypeChosedControl alloc] initWithFrame:CGRectMake(self.dateControl.left,  self.dateControl.bottom  +16, 200, 30)
                                                            title:@"焊子(00:00-00:59)"];
    [self.timeControl setClction:^(LGTypeChosedControl *control) {
        [weakSelf onSectedTimeControl];
    }];
    [header addSubview:self.timeControl];
    
    
    STButton * findButton = [[STButton alloc] initWithFrame:CGRectMake(0, self.timeControl.bottom + 20, 80, 30)
                                                      title:@"姓名测试"
                                                 titleColor:FirstTextColor
                                                  titleFont:14
                                               cornerRadius:4
                                            backgroundColor:FlatGray
                                            backgroundImage:nil
                                                      image:nil];
    findButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    [findButton setClicAction:^(UIButton *sender) {
        [weakSelf onSelctedTestButton];
    }];
    findButton.centerX = UIScreenWidth/2;
    [header addSubview:findButton];
                        
    
    header.height = findButton.bottom;
    self.tableView.tableHeaderView = header;
    
}
#pragma mark --Action Method
- (void)onSelctedTestButton{
    
}
- (void)onSectedDateControl{
    STPickerViewController * picker = [[STPickerViewController alloc] initWithDefualtDatePickerWithHandle:^(NSDate *date) {
        self.dateControl.title = date.st_yyyyMMddByLineWithDate;
    }];
    [self presentViewController:picker animated:NO completion:nil];
}
- (void)onSectedTimeControl{
    NSArray * array = @[
                        @"子时23：00～00：59",
                        @"丑时1：00～2：59",
                        @"寅时3：00～4：59",
                        @"卯时5：00～6：59",
                        @"辰时7：00～8：59",
                        @"巳时9：00～10：59",
                        @"午时11：00～12：59",
                        @"未时13：00～14：59",
                        @"申时15：00～16：59",
                        @"酉时17：00～18：59",
                        @"戌时19：00～20：59",
                        @"亥时21：00～22：59"];
    STPickerViewController * picker = [[STPickerViewController alloc] initWithPickerArray:@[array] andWithHandle:^(NSArray<NSString *> *stringArray) {
        self.timeControl.title = stringArray.lastObject;
    }];
    [self presentViewController:picker animated:NO completion:nil];
}
@end
